package com.jfirer.validator.descriptor;

import java.lang.reflect.Field;
import javax.validation.ConstraintValidatorFactory;
import javax.validation.Valid;
import javax.validation.metadata.PropertyDescriptor;

public class PropertyDescriptorImpl extends CascadableDescriptorImpl implements PropertyDescriptor
{
	private String propertyName;
	
	public PropertyDescriptorImpl(Field field, ConstraintValidatorFactory constraintValidatorFactory)
	{
		propertyName = field.getName();
		initializeCascadableDescriptor(field.isAnnotationPresent(Valid.class), defineGroupConversions(field.getAnnotations()));
		initializeElementDescriptor(field.getType(), defineConstraintDescriptors(constraintValidatorFactory, field.getAnnotations()));
	}
	
	@Override
	public String getPropertyName()
	{
		return propertyName;
	}
	
}
